import * as THREE from 'three/build/three.min.js';
// 控制器
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
// 加载器
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
// 单击选中模型高亮显示/选中模型发光
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer';
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass';
import { OutlinePass } from 'three/examples/jsm/postprocessing/OutlinePass';
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass';
import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader';
// label标签
import { CSS2DObject, CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer';
// TWEEN 动画
import TWEEN from 'three/examples/jsm/libs/tween.module.min.js';
import animations from './animations.js';

const GLTFloaderFn = new GLTFLoader();
GLTFloaderFn.setDRACOLoader(new DRACOLoader().setDecoderPath('https://threejs.org/examples/js/libs/draco/gltf/'));

// 模型居中显示
function setContent(scene) {
	// 获得包围盒得min和max
	const box = new THREE.Box3().setFromObject(scene);
	// 返回包围盒的中心点
	const center = box.getCenter(new THREE.Vector3());
	scene.position.x += scene.position.x - center.x;
	scene.position.y += scene.position.y - center.y + 35;
	scene.position.z += scene.position.z - center.z;
}

export {
	THREE,
	OrbitControls,
	EffectComposer,
	RenderPass,
	OutlinePass,
	ShaderPass,
	FXAAShader,
	CSS2DObject,
	CSS2DRenderer,
	TWEEN,
	animations,
	GLTFloaderFn,
	setContent
};
